//参考竞技游戏平台API说明
//扑克牌
const colorNo = {
  '1': '黑桃',
  '2': '红桃',
  '3': '梅花',
  '4': '方块',
};
const colorCardNo = {
  '1': 'A',
  '2': '2',
  '3': '3',
  '4': '4',
  '5': '5',
  '6': '6',
  '7': '7',
  '8': '8',
  '9': '9',
  '10': '10',
  '11': 'J',
  '12': 'Q',
  '13': 'K',
};

const colorDotNo = {
  '麻将': {
    '1': '1筒',
    '2': '2筒',
    '3': '3筒',
    '4': '4筒',
    '5': '5筒',
    '6': '6筒',
    '7': '7筒',
    '8': '8筒',
    '9': '9筒',
    '10': '白板',
  },
  '牌九': {
    '0': '天牌',
    '1': '地牌',
    '2': '人牌',
    '3': '鹅牌',
    '4': '梅牌',
    '5': '长三',
    '6': '板凳',
    '7': '斧头',
    '8': '红头十',
    '9': '高脚七',
    '10': '零霖六',
    '11': '杂九',
    '12': '杂九',
    '13': '杂八',
    '14': '杂八',
    '15': '杂七',
    '16': '杂七',
    '17': '杂五',
    '18': '杂五',
    '19': '丁三',
    '20': '二四',
  },
};
const formatChessBetDetail = (gameName, bets) => {
  let betDetails = '';
  let detail = [];
  if(bets){
    switch (gameName) {
      case '抢庄牛牛':
      case '抢庄三张':
      case '通比牛牛':
      case '炸金花':
      case '三公':
      case '看牌抢庄':
      case '经典牛牛':
      case '幸运五张':
      case '德州2+3':
      case '抢庄21点':
        _.each(bets, item => {
          detail.push(colorNo[item.colorNo] + colorCardNo[item.colorCardNo])
        });
        betDetails = detail.join(',')
        break;
      case '拼三张':
        _.each(bets, (item, index) => {
          let detailItem = ''
          switch (index) {
            case 0:
              detailItem = '上：';
              break;
            case 1:
              detailItem = '中：';
              break;
            case 2:
              detailItem = '下：';
              break;
          }
          let position = [];
          _.each(item, pos => {
            position.push(colorNo[pos.colorNo] + colorCardNo[pos.colorCardNo])
          });
          detail.push(detailItem + position.join(','))
        });
        betDetails = detail.join('<br/>')
        break;
      case '二八杠':
        _.each(bets, item => {
          detail.push(colorDotNo['麻将'][item.colorDotNo])
        });
        betDetails = detail.join('<br/>')
        break;
      case '抢庄牌九':
        _.each(bets, item => {
          detail.push(colorDotNo['牌九'][item.colorDotNo])
        });
        betDetails = detail.join(',')
        break;
      case '幸运21点':
        let rightCardList = bets.rightCardList;
        let playerCardList = bets.playerCardList;
        let playerCard = [];
        let rightCard = [];
        _.each(playerCardList, item => {
          playerCard.push(colorNo[item.colorNo] + colorCardNo[item.colorCardNo])
        });
        _.each(rightCardList, item => {
          rightCard.push(colorNo[item.colorNo] + colorCardNo[item.colorCardNo])
        });
        betDetails = '玩家：' + playerCard.join(',') + (rightCard.length > 0 ? ('<br/>右方' + rightCard.join(',')) : '')
        break;
      case '百人牛牛':
        _.each(bets, item => {
          let positionCard = [];
          let positionString = '';
          switch (item.seat) {
            case 1:
              positionString = '天:';
              break;
            case 2:
              positionString = '地:';
              break;
            case 3:
              positionString = '玄:';
              break;
            case 4:
              positionString = '黄:';
              break;
            case 0:
              positionString = '庄:';
              break;
          }
          _.each(item.cardList, pos => {
            positionCard.push(colorNo[pos.colorNo] + colorCardNo[pos.colorCardNo])
          });
          detail.push(positionString + positionCard.join(','));
        });
        betDetails = detail.join('<br/>');
        break;
      case '十三水':
        _.each(bets, (item, index) => {
          let detailItem = ''
          switch (index) {
            case 0:
              detailItem = '上：';
              break;
            case 1:
              detailItem = '中：';
              break;
            case 2:
              detailItem = '下：';
              break;
          }
          let position = [];
          _.each(item, pos => {
            position.push(colorNo[pos.colorNo] + colorCardNo[pos.colorCardNo])
          });
          detail.push(detailItem + position.join(','))
        });
        betDetails = detail.join('<br/>')
        break;
      case '欢乐斗牛':
        let blueCardList = bets.blueCardList;
        let redCardList = bets.redCardList;
        let blueCard = [];
        let redCard = [];
        _.each(blueCardList, item => {
          blueCard.push(colorNo[item.colorNo] + colorCardNo[item.colorCardNo])
        });
        _.each(redCardList, item => {
          redCard.push(colorNo[item.colorNo] + colorCardNo[item.colorCardNo])
        });
        betDetails = '蓝方：' + blueCard.join(',') + '<br/>红方' + redCard.join(',')
        break;

      case '大话骰':
        _.each(bets, item => {
          detail.push(item + '');
        });
        betDetails = detail.join(',')
        break;
    }
  }

  return betDetails;
};
export {

  formatChessBetDetail,
}

